public static int singleNonDuplicate(int[] nums) {
    int n = nums.length;
    for (int i = 0; i < n; i++) {
        if (i + 1 < n && nums[i + 1] == nums[i]) {
            continue;
        }
        if (i - 1 >= 0 && nums[i - 1] == nums[i]) {
            continue;
        }
        return nums[i];

    }
    return nums[0];
}
public static int singleNonDuplicate1(int[] nums) {
    int low = 0;
    int high = nums.length - 1;
    while (low < high) {
        int mid = (high - low) / 2 + low;
        if (nums[mid] == nums[mid ^ 1]) {
            low = mid + 1;
        } else {
            high = mid;
        }
    }
    return nums[low];
}